package com.xialing.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author: xialing
 * @Description
 */
@Configuration
@Slf4j
public class SnowFlakeWordIdConfig {


    static {
        try {
         InetAddress address = InetAddress.getLocalHost();
         String hostAddressIp = address.getHostAddress();

         String workId = Math.abs(hostAddressIp.hashCode()) % 1024 + "";

         System.setProperty("workId", workId);

         log.info("workId:{}", workId);

        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
